using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Text.Classification;
using Microsoft.VisualStudio.Text.Tagging;
using Microsoft.VisualStudio.Utilities;

namespace Behaviorize.TextEditor.Coloring
{
	[Export(typeof(ITaggerProvider))]
	[ContentType("feature")]
	[TagType(typeof(ClassificationTag))]
	internal sealed class ColorTaggerProvider : ITaggerProvider
	{

		[Export]
		[Name("feature")]
		[BaseDefinition("code")]
		internal static ContentTypeDefinition FeatureContentType = null;

		[Export]
		[FileExtension(".feature")]
		[ContentType("feature")]
		internal static FileExtensionToContentTypeDefinition FeatureFileType = null;

		[Import]
		internal IClassificationTypeRegistryService ClassificationTypeRegistry = null;

		[Import]
		internal IBufferTagAggregatorFactoryService AggregatorFactory = null;

		public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
		{
			ITagAggregator<ColorTag> featureTagAggregator = AggregatorFactory.CreateTagAggregator<ColorTag>(buffer);
			return new ColorClassifier(featureTagAggregator, ClassificationTypeRegistry) as ITagger<T>;
		}
	}
}